package priv.yiyuan.example.design.factory;

import priv.yiyuan.example.design.device.PlaybackDevice;
import priv.yiyuan.example.design.device.Television;
import priv.yiyuan.example.design.player.ImagePlayer;
import priv.yiyuan.example.design.player.MediaPlayer;
import priv.yiyuan.example.design.player.MoviePlayer;
import priv.yiyuan.example.design.player.MusicPlayer;

/**
 * 电视播放器工厂
 * <p>
 * 工厂方法模式(具体创建者)
 */
public class TelevisionPlayerFactory implements MediaPlayerFactory {

    private PlaybackDevice television;

    public TelevisionPlayerFactory(String name) {
        this.television = new Television(name);
    }

    @Override
    public MediaPlayer createMoviePlayer() {
        System.out.println("为电视创建电影播放器.");
        return new MoviePlayer(television);
    }

    @Override
    public MediaPlayer createMusicPlayer() {
        System.out.println("为电视创建音乐播放器.");
        return new MusicPlayer(television);
    }

    @Override
    public MediaPlayer createImagePlayer() {
        System.out.println("为电视创建图片播放器.");
        return new ImagePlayer(television);
    }
}
